const express = require('express')
const router = express.Router()

const db = require('../../db/conn_blog')
const responsed = require('../../utils/response')

router.get('/', async (req, res, next) => {
  const result = await db.getStudySubmenu().catch(err => err)

  if (result === 'DATABASE ERROR, connection failed!')
    res.json(responsed(0, '获取目录信息失败, DATABASE ERROR , connection failed!', false))

    if (result.length > 0) res.json(responsed(1, '获取目录信息成功', result))
    else res.json(responsed(0, '获取目录信息失败', false))
})

module.exports = router